package com.wlz.broadcast;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

/**
 * @author： wlz
 * @Date 2020/10/29 15:10
 * @description： TODO 消息生产端
 * @version: 1.0
 */
public class BroadcastProducer {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
        producer.setNamesrvAddr("192.168.27.133:9876");
        producer.start();

        for (int i = 0; i < 10; i++) {
            String body = "broadcastmsg" + i;
            Message msg = new Message("broadcastTopic","TagA","orderID188",
                    body.getBytes());

            SendResult sendResult = producer.send(msg);
            System.out.printf("%s%n",sendResult);
        }

        producer.shutdown();
    }
}
